import request from '../../request';
import { AxiosResponse } from 'axios';
import { ResponseData } from '@/types/api/public';
import { TableList,EditData,InnerFormInput } from '@/types/api/workflow/innerform';

type ConfigType<T=ResponseData> = Promise<AxiosResponse<T>>

/**
 * 获取数据
 * @param params 参数
 * @returns 分页数据
 */
export const getInnerFormPageData =(params:any):ConfigType<TableList> =>{
    params.PageIndex=params.current;
    params.PageSize=params.pageSize;
    return request({
       url:'/api/v1/InnerForm/GetInnerFormPageList',
       method:'get',
       params,   
       headers: {
        'Content-Type': 'application/json'
      } 
    })
}

export const getNodeFormData =(params:any):ConfigType<TableList> =>{
  return request({
     url:'/api/v1/InnerForm/GetNodeFormList',
     method:'get',
     params,   
     headers: {
      'Content-Type': 'application/json'
    } 
  })
}

export const getAllFormData =():ConfigType<TableList> =>{
  return request({
     url:'/api/v1/InnerForm/GetInnerFormAllList',
     method:'get',
     headers: {
      'Content-Type': 'application/json'
    } 
  })
}

export const delNodeFormData =(params:any):ConfigType<TableList> =>{
  return request({
     url:'/api/v1/InnerForm/DeleteNodeForm',
     method:'get',
     params,
     headers: {
      'Content-Type': 'application/json'
    } 
  })
}

export const getNodeForm =(params:any):ConfigType<TableList> =>{
  return request({
     url:'/api/v1/InnerForm/GetNodeForm',
     method:'get',
     params,
     headers: {
      'Content-Type': 'application/json'
    } 
  })
}

export const saveOrUpdateNodeForm =(data:any):ConfigType<TableList> =>{
  return request({
     url:'/api/v1/InnerForm/SaveOrUpdateNodeForms',
     method:'post',
     data,   
     headers: {
      'Content-Type': 'application/json'
    } 
  })
}

export const saveOrUpdateInnerForm =(data:any):ConfigType<TableList> =>{
    return request({
       url:'/api/v1/InnerForm/SaveOrUpdateInnerForm',
       method:'post',
       data,   
       headers: {
        'Content-Type': 'application/json'
      } 
    })
  }

  export const deleteInnerForm =(params:any):ConfigType<TableList> =>{
    return request({
       url:'/api/v1/InnerForm/DeleteInnerFormById',
       method:'delete',
       params,   
       headers: {
        'Content-Type': 'application/json'
      } 
    })
}